package PersonInformation;

import java.util.Scanner;

public class Tool {
    Scanner s=new Scanner(System.in);

    //菜单
    public void menu(){
        System.out.println("          1.增加元素");
        System.out.println("          2.删除元素");
        System.out.println("          3.查找单个元素");
        System.out.println("          4.更改元素");
        System.out.println("          5.遍历元素");
        System.out.println("          6.退出");
    }
    //判断是否执行此操作
    public boolean readyn(){
        System.out.println("判断是否执行此操作");
        String x=s.nextLine();
        if(x=="y")
            return true;
        else
            return false;
    }
    //读取年龄
    public int readAge(){
        while(true){
            int ret=s.nextInt();
            if(ret>150||ret<0){
                System.out.println("输入有误请重新输入");
            }else{
                return ret;
            }
        }

    }
    //读取名字
    public String readName(){
        while(true){
            String ret=s.nextLine();
            if(ret.length()<=0||ret.length()>3){
                System.out.println("输入有误请重新输入");
            }else{
                return ret;
            }
        }
    }
    //读取性别
    public String readGender(){
        while(true){
            String ret=s.nextLine();
            if(ret.length()==1){
              return ret;
            }else{
                System.out.println("输入有误请重新输入");
            }
        }
    }
    //读取电话号码
    public String readTelephone(){
        while(true){
            String ret=s.nextLine();
            if(ret.length()!=11){
                System.out.println("输入有误请重新输入");
            }else{
                return ret;
            }
        }
    }

}
